package com.tarena.sentinel.demo02.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Service;

@Service
public class HelloService {

    @SentinelResource(value = "resource02",blockHandler = "degradeHandler")
    public String sayHi(String name){
        try {
            Thread.sleep(51); //百分百会触发熔断
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "hello ["+name+"],sentinel welcome";
    }

    public String degradeHandler(String name, BlockException e){
        return "sayHi资源被熔断了...";
    }

}
